package cn.smbms.tools;

public class ResponseResult {
	 
    private int code;
 
    private String message;
 
    private Object data;
    
    private ResponseResult(){
    	
    }
    
    public ResponseResult(int code, String message, Object data) {
		this.code = code;
		this.message = message;
		this.data = data;
	}

    public void setResultCode(ResultCode resultCode){
    	this.code = resultCode.code();
    	this.message = resultCode.message();
    }
    
    //返回成功
	public static  ResponseResult ok() {
		ResponseResult result = new ResponseResult();
		result.setResultCode(ResultCode.OK_200);
		return result;
    }
 
	//返回成功
    public static  ResponseResult ok(Object data) {
    	ResponseResult result = new ResponseResult();
		result.setResultCode(ResultCode.OK_200);
		result.setData(data);
		return result;
    }
 
    //返回成功
    public static ResponseResult ok(String message) {
    	ResponseResult result = new ResponseResult();
		result.setMessage(message);
		return result;
    }
    
    //返回成功
    public static ResponseResult ok(Object data, String message) {
    	ResponseResult result = new ResponseResult();
		result.setMessage(message);
		result.setData(data);
		return result;
    }
 
    //返回失败
    public static  ResponseResult failed(int code, String message) {
    	ResponseResult result = new ResponseResult();
		result.setCode(code);
		result.setMessage(message);
		return result;
    }
    //返回失败
    public static  ResponseResult failed(int code) {
    	ResponseResult result = new ResponseResult();
		result.setCode(code);
		return result;
    }
    
    //返回失败
    public static  ResponseResult failed(String message) {
    	ResponseResult result = new ResponseResult();
		result.setMessage(message);
		return result;
    }
 
	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public Object getData() {
		return data;
	}

	public void setData(Object data) {
		this.data = data;
	}
}
